package o;

import android.text.TextUtils;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment.b;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appmarket.service.activitydispatcher.OpenGateway;
import com.huawei.appmarket.service.activitydispatcher.OpenGateway$c;
import com.huawei.appmarket.service.appmgr.view.activity.AppManagerProtocol;
import com.huawei.appmarket.service.externalapi.bean.OpenMarketResponse;
import com.huawei.appmarket.service.externalapi.view.NoNetworkLoadingFragment;
import com.huawei.appmarket.service.externalapi.view.ThirdApiActivity.a;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.List;
import org.json.JSONObject;

public abstract class dpb {

    public static class d extends a {
        public d(String str, dys.a aVar) {
            super(str, aVar);
        }

        public boolean ˋ(TaskFragment taskFragment, b bVar) {
            boolean ˊ = dpb.ˊ(this.ˏ, bVar.ˋ);
            if (!ˊ && (taskFragment instanceof NoNetworkLoadingFragment)) {
                ((NoNetworkLoadingFragment) taskFragment).ॱ();
            }
            return ˊ;
        }

        public void ˎ(TaskFragment taskFragment, List<cvt> list) {
            dyi o_dyi = new dyi();
            o_dyi.openStr_ = this.ˋ;
            list.add(o_dyi);
        }
    }

    public static boolean ˊ(dys.a aVar, ResponseBean responseBean) {
        OpenMarketResponse openMarketResponse;
        if (responseBean.getResponseCode() == 0 && (responseBean instanceof OpenMarketResponse) && responseBean.getRtnCode_() == 0) {
            openMarketResponse = (OpenMarketResponse) responseBean;
            OpenGateway$c ˊ = OpenGateway.ˊ(openMarketResponse.ˋ(), openMarketResponse.ॱ(), false);
            if (ˊ != null) {
                if (ˊ.ˎ() != null) {
                    aVar.ˎ(ˊ.ˎ(), 0);
                } else if (ˊ.ˏ() != null) {
                    aVar.startActivity(ˊ.ˏ());
                } else if (ˊ.ˊ() != null) {
                    aVar.ˏ(ˊ.ˊ().ˋ, ˊ.ˊ().ˏ);
                } else {
                    Logger.e("OnlineStartActivity", "can not start target activity.Go MainActivity");
                }
            }
            aVar.finish();
            return true;
        } else if (responseBean.getResponseCode() != 0 || responseBean.getRtnCode_() != 2) {
            return false;
        } else {
            if (responseBean instanceof OpenMarketResponse) {
                openMarketResponse = (OpenMarketResponse) responseBean;
                if (!TextUtils.isEmpty(openMarketResponse.ˎ())) {
                    evk.ˋ(ContentManager.getInstant().getContext(), openMarketResponse.ˎ(), 0).ˋ();
                }
            }
            Logger.e("OnlineStartActivity", "OnCompleted RTNCODE 2!");
            aVar.finish();
            return true;
        }
    }

    public static void ˏ(dys.a aVar, String str) {
        if (!ˊ(aVar, str)) {
            aVar.ॱ(new d(str, aVar));
        }
    }

    public static boolean ˊ(dys.a aVar, String str) {
        if (TextUtils.isEmpty(str)) {
            Logger.e("OnlineStartActivity", "error openStr,can not open.");
            aVar.finish();
            return false;
        }
        String ॱ = ॱ(str);
        if (ॱ.equals("3")) {
            aVar.ˊ("main.activity");
        } else if (ॱ.equals(HwAccountConstants.TYPE_SINA)) {
            r1 = new AppManagerProtocol();
            r1.ˊ().ॱ(false);
            aVar.ˎ(r1.ˏ(), 0);
        } else if (ॱ.equals(HwAccountConstants.TYPE_SECURITY_PHONE)) {
            r1 = new AppManagerProtocol();
            r1.ˊ().ॱ(false);
            aVar.ˎ(r1.ˎ(), 0);
        } else if (!ॱ.equals("5")) {
            return false;
        } else {
            aVar.ˊ("main.activity");
        }
        aVar.finish();
        return true;
    }

    private static String ॱ(String str) {
        String str2 = "";
        try {
            Object obj = new JSONObject(str).get("openId");
            if (obj instanceof String) {
                return (String) obj;
            }
        } catch (Throwable e) {
            Logger.ˋ("OnlineStartActivity", "openId is error!!", e);
        }
        return str2;
    }
}
